home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-04
/
pxewin.zip
/
PXDISPLY.HPP
< prev
next >
Wrap
C/C++ Source or Header
|
1992-01-08
|
4KB
|
149 lines
// PXDISPLY.HPP //
// Contents ----------------------------------------------------------------
//
// PXDIS class for opening a table and initializing the record buffer
// and all the fields.
//
// Description -------------------------------------------------------------
//
// This header contains classes for displaying a Paradox database in
// Windows.
//
// End ---------------------------------------------------------------------
// External Reference Name for this Header ---------------------------------
#ifndef PXDISPLY_HPP
#define PXDISPLY_HPP
// End ---------------------------------------------------------------------
// Interface Dependencies --------------------------------------------------
#ifndef PXSTRUCT_HPP
#include "pxstruct.hpp"
#endif
// End ---------------------------------------------------------------------
// enum DISPLAY //
enum DISPLAY
{
RECORD, /* One record is displayed
per window. */
PAGE /* A page of records are
displayed in a window. */
};
// class PXDIS //
class PXDIS:public PXRec
{
public:
PXField **my_field; /* Fields list */
PXDIS::PXDIS()
{
// NULL out all your field pointer.
my_field = NULL;
}
int SetUp(int index,int mode, /* Set up database */
int op,int display);
~PXDIS(void); /* Destroy display */
char *Get(int i) /* Get the data from the
right field */
{
return my_field[i]->Get();
}
};
// Description -------------------------------------------------------------
//
// This is the display class that allows displaying a database in a
// window.
//
// End ---------------------------------------------------------------------
int PXDIS::SetUp(int index,int mode,int op,int display)
{
int i; /* Field index */
FIELDHANDLE fld;
// Null out your pointers in case a delete is called before
// new
my_field = NULL;
// Open the table
if(PXTbl::Open(index,mode,op) != PXSUCCESS)
return pxerr;
// Open record buffer and get the number of records in table
if(PXRec::Open() != PXSUCCESS)
return pxerr;
// Get the number of fields in the table
NumFlds();
// Make an array of field pointers
my_field = new PXField* [num_fields];
// Get the fields initialized
for(i = 0;i < num_fields;i++)
{
fld = i + 1;
my_field[i] = new PXField(&tblHandle,&recHandle,fld);
}
return PXSUCCESS;
}
// Summary -----------------------------------------------------------------
//
// This member initializes the table for display in a window
//
// Parameters --------------------------------------------------------------
//
// name. This is the name of the database.
//
// index. This the index you wish to use.
//
// mode. This is the save mode you wish to open the table with.
//
// op. This is the operation you wish to perform on the table. You
// can also use the create operation.
//
// display. This is the display option you wish to perform. You can
// dislay a single record at a time or a page of records.
//
// Function Description ----------------------------------------------------
//
// 1. Make table object.
//
// 2. Make record object.
//
// 3. Get the number of fields in the table.
//
// 4. Make all your field objects.
//
// End ---------------------------------------------------------------------
// destructor PXDIS //
PXDIS::~PXDIS(void)
{
int i; /* field index */
for(i = 0;i < num_fields;i++)
delete my_field[i];
delete my_field;
}
#endif